#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int get_days(int year, int month)
{
	int arr[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	//        0  1  2  3  4  5  6  7  8  9  10 11 12  
	if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
	{
		if (month == 2)
		{
			return arr[month] + 1;
		}
		else
		{
			return arr[month];
		}
	}
	else
		return arr[month];
}

int main()
{
	int year = 0;
	int month = 0;
	while (scanf("%d %d", &year, &month) != EOF)
	{
		int days = get_days(year, month);
		printf("%d\n", days);
	}
	return 0;
}